package org.jeecg.modules.health_records.health_specialcheck.service.impl;

import org.jeecg.modules.health_records.health_specialcheck.entity.HealthSpecialCheckInfo;
import org.jeecg.modules.health_records.health_specialcheck.mapper.HealthSpecialCheckInfoMapper;
import org.jeecg.modules.health_records.health_specialcheck.service.IHealthSpecialCheckInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Description: 体格检查-专项检查记录表
 * @Author: jeecg-boot
 * @Date:   2025-08-11
 * @Version: V1.0
 */
@Service
public class HealthSpecialCheckInfoServiceImpl extends ServiceImpl<HealthSpecialCheckInfoMapper, HealthSpecialCheckInfo> implements IHealthSpecialCheckInfoService {
    @Autowired
    private HealthSpecialCheckInfoMapper healthSpecialCheckInfoMapper;
    /**按recordid查询**/
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthSpecialCheckInfo> queryByRecordId(HealthSpecialCheckInfo healthSpecialCheckInfo) {
        return healthSpecialCheckInfoMapper.queryByRecordId(Long.valueOf(healthSpecialCheckInfo.getRecordid()), healthSpecialCheckInfo.getIdNumber());

    }
    /**电子病历信息查询接口（查询时间最新的那条数据）--按recordid查询**/
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthSpecialCheckInfo> queryElecRecord(HealthSpecialCheckInfo healthSpecialCheckInfo) {
        return healthSpecialCheckInfoMapper.queryElecRecord(Long.valueOf(healthSpecialCheckInfo.getRecordid()), healthSpecialCheckInfo.getIdNumber());

    }
    //新规则查询当下时间往前12个月的就诊数据作为电子病历数据
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthSpecialCheckInfo> newQueryElecRecord(HealthSpecialCheckInfo healthSpecialCheckInfo) {
        return healthSpecialCheckInfoMapper.newQueryElecRecord(Long.valueOf(healthSpecialCheckInfo.getRecordid()),healthSpecialCheckInfo.getSeeId(),healthSpecialCheckInfo.getIdNumber());

    }

    //新规则：除去当下时间往前12个月的就诊数据，剩下的数据为既往病历数据
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthSpecialCheckInfo> newQueryPastRecord(HealthSpecialCheckInfo healthSpecialCheckInfo) {
        return healthSpecialCheckInfoMapper.newQueryPastRecord(Long.valueOf(healthSpecialCheckInfo.getRecordid()),healthSpecialCheckInfo.getSeeId(),healthSpecialCheckInfo.getIdNumber());

    }
    
}
